#!/bin/bash

# 安装Selenium网站访问器所需依赖

echo "=== 安装Selenium依赖 ==="

# 检查Python3
if ! command -v python3 &> /dev/null; then
    echo "❌ 未找到Python3，请先安装Python3"
    exit 1
fi

echo "✅ Python3版本: $(python3 --version)"

# 安装pip包
pip3 install selenium numpy

# 检查Chrome浏览器
if ! command -v google-chrome &> /dev/null && ! command -v chromium-browser &> /dev/null; then
    echo "⚠️  未找到Chrome浏览器，请安装Chrome或Chromium"
    echo "Ubuntu/Debian安装命令: sudo apt-get install chromium-browser"
fi

# 检查Chrome驱动
echo "检查Chrome驱动..."
if command -v chromedriver &> /dev/null; then
    echo "✅ Chrome驱动已安装"
    echo "驱动路径: $(which chromedriver)"
else
    echo "❌ 未找到Chrome驱动"
    echo "请按以下步骤安装:"
    echo "1. 查看Chrome版本: google-chrome --version"
    echo "2. 从 https://chromedriver.chromium.org/ 下载对应版本的驱动"
    echo "3. 解压后放到 /usr/local/bin/ 目录"
    echo "4. 设置权限: sudo chmod +x /usr/local/bin/chromedriver"
fi

echo ""
echo "=== 安装完成 ==="
echo "运行命令: python3 selenium_website_visitor.py"